package localdate01;

import java.time.LocalDate;

/*
* LocalDate设置功能
*   static LocalDate of(int year, int month, int dayOfMonth)
*   LocalDate withYear(int year) //设置指定日期的年
*   LocalDate withMonth(int month)//设置月
*   LocalDate withDayOfYear(int dayOfYear)//设置这一年第几天
*   LocalDate withDayOfMonth(int dayOfMonth)//设置日
* */
public class LocalDateDemo02 {
    public static void main(String[] args) {
        method01();

        LocalDate nowDate2 = LocalDate.now().withYear(2022);
        System.out.println(nowDate2); //  2022-04-18
        System.out.println(nowDate2.withMonth(3));     //  2022-03-18
        System.out.println(nowDate2.withDayOfMonth(18)); //  2022-04-18
        System.out.println(nowDate2.withDayOfYear(10)); // 2022-01-10


    }

    private static void method01() {
        System.out.println(LocalDate.now());   // 2024-04-18

        LocalDate nowDate = LocalDate.of(2024,10,20);
        System.out.println(nowDate);   //  2024-10-20  of方法可以设置指定的年月日
    }
}
